package view
{
	import controller.Application;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import res.WinTipMc;

	public class WinTip extends Sprite
	{
		private var message:String;
		
		public function WinTip(message:String)
		{
			this.message = message;
			
			if (stage)init();
			else
				addEventListener(Event.ADDED_TO_STAGE, init);			
		}
		
		
		private function init(e:Event=null):void
		{
			var mask:Sprite = new Sprite();
			mask.graphics.beginFill(0x0, 0.2);
			mask.graphics.drawRect(0,0, stage.stageWidth, stage.stageHeight);
			mask.graphics.endFill();
			
			addChild(mask);
			
			var mc:WinTipMc = new WinTipMc();
			mc.txt_message.htmlText = message;
			
			mc.x = 400;
			mc.y = 170;
			addChild(mc);
			addEventListener(MouseEvent.CLICK, clickHandler);
		}
		
		private function clickHandler(e:MouseEvent):void
		{
			Application.getInstance().mainMc.removeChild(this);
		}
		
		
		/**
		 * 显示 
		 * @param message
		 * 
		 */		
		public static function show(message:String):void
		{
			var dialog:WinTip = new WinTip(message);
			Application.getInstance().mainMc.addChild(dialog);
		}
	}
}